#include <stdio.h>
#include "DataMiningManager.h"
#include "DataMiningStruct.h"
#include <Windows.h>
#include <time.h>
//#include "staticTest.h"

int main()
{
	
	{
		DataMiningManager miningManager;
		BuyData buyData;
		buyData.itemId = 3012;
		buyData.roleId = 10000;
		EquipStrenData equipData;
		equipData.itemId = 3012;
		equipData.itemLevel = 12;
		equipData.roleId = 10000 ;
		RechargeData rechargeData;
		rechargeData.moneyAccount = 2000 ;
		rechargeData.roleId = 10000;
		int_x currentTime = static_cast< int_x >( time(NULL) );
		int_x oldTime = currentTime + 100;
		int_x loop = 0 ;
		while ( currentTime < oldTime)
		{
			miningManager.trace( &buyData, DATA_MINING_TYPE_BUYDATA );
			miningManager.trace( &equipData, DATA_MINING_TYPE_EQUIPSTRENDATA );
			miningManager.trace( &rechargeData, DATA_MINING_TYPE_RECHARGE ) ;
			currentTime = static_cast< int_x >( time(NULL) );
			printf( "%d \n", loop++ );
			Sleep(1000);
			
		}

	}

	
	FILE* datamingfile = fopen( "1341301620","rb");
	while ( feof(datamingfile) == 0 )
	{
		int_x structType;
		fread(&structType, sizeof(int_x), 1, datamingfile );
		if ( structType == DATA_MINING_TYPE_BUYDATA )
		{

			BuyData data;
			fread( &data, sizeof(data), 1, datamingfile );
			if ( data.dataType != structType )
			{
			}
			else
			{
				printf("ItemId: %d RoleId:%d \n", data.itemId, data.roleId );
			}
		}
		else if ( structType == DATA_MINING_TYPE_EQUIPSTRENDATA )
		{
			EquipStrenData data;
			fread( &data, sizeof(data), 1, datamingfile );
			if ( data.dataType != structType )
			{
			}
			else
			{
				printf("ItemId :%d, ItemLevel :%d, RoleId :%d \n", data.itemId, data.itemLevel, data.roleId );
			}
		}
		else if ( structType == DATA_MINING_TYPE_RECHARGE )
		{
			RechargeData data;
			fread( &data, sizeof(data), 1, datamingfile );
			if ( data.dataType != structType )
			{
				continue;
			}
			else{
				printf( "RoleId :%d MoneyAccount :%d \n",data.roleId, data.moneyAccount);
			}
		}
		else{}
	}
	printf("Analyse OK ~ ");
	
	return 0;
}